using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BigFishSkillGrind : MonoBehaviour
{
    // Start is called before the first frame update
    public GameObject[] grinding1;
    Transform ttransform;
    Transform playertransform;
    float CDtime;
    public float CD;
    public int grindtime;
    void Start()
    {
        ttransform = GetComponent<Transform>();
        playertransform = GameObject.FindWithTag("Player").GetComponent<Transform>();
    }
    private void Update()
    {
       if (CDtime > 0)
        {
            CDtime -= Time.deltaTime;
        }
        else
        {
            grind1();
            CDtime = CD;
        }
    }
    // Update is called once per frame
    void grind1()
    {
        for (int i = 1; i <= grindtime; i++)
        {
            Vector3 position = ttransform.position;
            position.x += Random.Range(-3.0f, 3.0f);
            Instantiate(grinding1[Random.Range(0, grinding1.Length)], position, Quaternion.identity, transform);
        }
        Transform[] myTransforms = GetComponentsInChildren<Transform>();
        foreach (var child in myTransforms)
            if (child.gameObject.CompareTag("Enemy")) child.parent = null;
    }
}
